import Vue from 'vue'
// div拖拽功能
const drag = Vue.directive('drag', {
    bind (el, binding) {
        el.onmousedown = e => {
            let x = e.pageX - el.offsetLeft
            let y = e.pageY - el.offsetTop
            document.onmousemove = e => {
                el.style.left = `${e.pageX - x}px`
                el.style.top = `${e.pageY - y}px`
            }
            document.onmouseup = () => {
                document.onmousemove = document.onmousedown = null
            }
            e.preventDefault()
        }
    }
})
export default { drag }
